package com.xiaomaoguai.cloud.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.xiaomaoguai.cloud.entity.User;
import com.xiaomaoguai.cloud.service.IUserService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * User 控制层
 *
 * @ ClassName: UserController.java
 * @ Author: WeiHui-Z
 * @ Date: 2016/12/6 12:36
 * @ Version: v1.0.0
 */
@RestController
@RequestMapping("/user")
public class UserController {

	@Autowired
	private IUserService userService;

	@GetMapping("/{id:[0-9]*}")
	@ApiOperation(value = "获取用户信息", notes = "参数描述", code = 200, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public User getUserInfo(@ApiParam(name = "id", value = "编号", required = true) @PathVariable Long id) {
		return userService.selectById(id);
	}

	/**
	 * 分页 PAGE
	 */
	@GetMapping("/test3")
	@ApiOperation(value = "获取用户分页信息", notes = "参数描述", code = 200, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public Page<User> test3() {
		return userService.selectPage(new Page<>(0, 12));
	}
}